package cn.edu.hy.demo06.controller;

import cn.edu.hy.demo06.entity.Student;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("student")
public class StudentController {

    /**
     * 返回页面
     */
    @GetMapping(value = {"","index"})
    public ModelAndView studentIndex(){

        return  new ModelAndView("demo06/studentIndex");
    }

    /**
     * ajax返回页面数据
     */
    @PostMapping("getStudent")
    @ResponseBody
    public Student getStudent(String id){

        System.out.println("前端传过来的请求参数是："+id);

        return new Student("王同学",185);
    }


}
